home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Freeware 2002 November
/
SGI Freeware 2002 November - Disc 3.iso
/
relnotes
/
shared
/
js
/
style_sniffer.js
< prev
Wrap
Text File
|
2002-10-07
|
1KB
|
35 lines
// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();
// *** BROWSER VERSION ***
var vers = parseInt(navigator.appVersion);
// *** BROWSER TYPE ***
var nn = (
(agt.indexOf('mozilla')!=-1) &&
(agt.indexOf('gecko')==-1) && (agt.indexOf('compatible')==-1) &&
(agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1)
);
var nav4 = (nn && (vers >= 4));
var ie = (agt.indexOf("msie") != -1);
var ie4 = (ie && (vers >= 4));
var moz = (agt.indexOf("gecko") != -1);
// *** PLATFORM ***
var is_win = (agt.indexOf("win")!=-1);
var is_mac = (agt.indexOf("mac")!=-1);
var is_unix = (agt.indexOf("x11")!=-1);
// Select the appropriate stylesheet
if (nav4 || ie4 || (!nn && !ie)) {
var isFour = true;
// var styles = ((location.host != "www.sgi.com")?location.protocol+"//www.sgi.com/":"/") + "styles/";
var styles = ((location.protocol == "file:") ? "" :
((location.host != "www.sgi.com")?location.protocol+"//www.sgi.com/":"/")) + "styles/";
if (is_win) styles += (nn)?"win_ns.css":"win_ie.css"; // Microsoft Windows
else if (is_mac) styles += (nn)?"mac_ns.css":"mac_ie.css"; // Apple Macintosh
else styles += (nn)?"unix.css":"win_ie.css"; // UNIX
document.write('<LINK REL="stylesheet" HREF="' + styles + '" TYPE="text/css">');
}